package com.beanutil.examples;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.LazyDynaBean;

public class BeanUtilExample2 {


	public static void main(String[] args) {
		LazyDynaBean person=new LazyDynaBean();
		//person 对象是被动态生成的 不存在实际的person类
		person.set("interest", "运动");
		person.set("lastVisited", new java.util.Date());
		
		System.out.println(person.get("interest"));
		System.out.println(person.get("lastVisited"));
		
		try {
			System.out.println(BeanUtils.getProperty(person, "interest"));
			System.out.println(BeanUtils.getProperty(person, "lastVisited"));

		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		}
	}
}
